export default class Deque {
	#items = []
	addFront(element) {
		this.#items.unshift(element)
	}

	addBack(element) {
		this.#items.push(element)
	}

	removeFront() {
		return this.#items.shift()
	}

	removeBack() {
		return this.#items.pop()
	}

	peekFront() {
		if (this.isEmpty()) {
			return undefined
		}
		return this.#items[0]
	}
	peekBack() {
		if (this.isEmpty()) {
			return undefined
		}
		return this.#items[this.size() + 1]
	}

	isEmpty() {
		return this.#items.length === 0
	}

	size() {
		return this.#items.length
	}

	clear() {
		this.#items = []
	}
}
